Option Explicit On Option Strict On Public Class Form1 Inherits System.Windows.Forms.Form Const adjustAmount As Integer = 10 Const waitfactor As Integer = 4000000 Const titleBarSize As Integer = 34 Private Sub wait(ByVal howLong As Integer) Dim t As Integer For t = 1 To howLong ' do nothing Dim dummy As Integer dummy = t + t + t Next t End Sub #Region " Windows Form Designer generated code " ... #End Region Private Sub BtnRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnRight.Click Dim cnt As Integer Dim times As Integer Dim isConverted As Boolean isConverted = Integer.TryParse(TxtTimes.Text, times) If isConverted Then For cnt = 1 To times BtnPlay1.Left = BtnPlay1.Left + adjustAmount If BtnPlay1.Left > Me.Width - BtnPlay1.Width Then BtnPlay1.Left = Me.Width - BtnPlay1.Width End If wait(waitfactor) Next cnt Else MsgBox("you must have a whole number in the text box") End If End Sub Private Sub BtnLeft_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLeft.Click Dim cnt As Integer Dim times As Integer Dim isConverted As Boolean isConverted = Integer.TryParse(TxtTimes.Text, times) If isConverted Then For cnt = 1 To times BtnPlay1.Left = BtnPlay1.Left - adjustAmount If BtnPlay1.Left < 0 Then BtnPlay1.Left = 0 End If wait(waitfactor) Next cnt Else MsgBox("you must have a whole number in the text box") End If End Sub Private Sub BtnUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnUp.Click Dim cnt As Integer Dim times As Integer Dim isConverted As Boolean isConverted = Integer.TryParse(TxtTimes.Text, times) If isConverted Then For cnt = 1 To times BtnPlay1.Top = BtnPlay1.Top - adjustAmount If BtnPlay1.Top < 0 Then BtnPlay1.Top = 0 End If wait(waitfactor) Next cnt Else MsgBox("you must have a whole number in the text box") End If End Sub Private Sub BtnDown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDown.Click Dim cnt As Integer Dim times As Integer Dim isConverted As Boolean isConverted = Integer.TryParse(TxtTimes.Text, times) If isConverted Then For cnt = 1 To times BtnPlay1.Top = BtnPlay1.Top + adjustAmount If BtnPlay1.Top > Me.Height - (BtnPlay1.Height + titleBarSize) Then BtnPlay1.Top = Me.Height - (BtnPlay1.Height + titleBarSize) End If wait(waitfactor) Next cnt Else MsgBox("you must have a whole number in the text box") End If End Sub End Class